<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/2/28 0028
 * Time: 15:42
 */
include "config.php";
$uId = $_POST["uid"];
$gId = $_POST["gid"];
$num = $_POST["num"];
$sql = "UPDATE `cartinfo` SET num =".$num.",uTotal=gPrice*num WHERE `gId`=".$gId." AND `uid`=".$uId.";";
$result = $conn->query($sql);
$sql2 = "SELECT num,uTotal FROM `cartinfo` WHERE `gId`=".$gId." AND `uid`=".$uId.";";
$result2 = $conn->query($sql2);

//$sql3 = "SELECT SUM(num),SUM(uTotal) FROM `cartinfo` WHERE `uid`="";"
//$arr = array("data1"=>);
print_r(json_encode($result2->fetch_assoc()));


$conn->close();